
#include "NodeDirection.h"
#include <utility>

using namespace npInterpreter;
using namespace std;


NodeDirection::NodeDirection() : Node() // class inheritance
{
    //To initialize data member;
    this->direction = "";
}

NodeDirection::~NodeDirection()
{
    //To delete dynamic data member
}

NodeDirection::NodeDirection(const NodeDirection& cpy) : Node(cpy) // class inheritance
{
    //To copy data member
    this->direction = cpy.direction;
}

NodeDirection& NodeDirection::operator=(const NodeDirection& asn)
{
    if (this == &asn)
    {
        return *this;
    }
    else
    {
        //To invoke base class operator=
        Node::operator=(asn);
        //To assign data member, note to delete dynamic member if exists.
        this->direction = asn.direction;

        return *this;
    }
}

NodeDirection::NodeDirection(NodeDirection&& mov) noexcept : Node(move(mov)) // class inheritance
{
    //to move data
    this->direction = move(mov.direction);
}

NodeDirection& NodeDirection::operator=(NodeDirection&& mva) noexcept
{
    if (this == &mva)
    {
        return *this;
    }
    else
    {
        //to inform base class to move data
        Node::operator=(move(mva));
        // to move data
        this->direction = move(mva.direction);
        
        return *this;
    }
}

NodeDirection* NodeDirection::clone() const
{
    //return new
    return new NodeDirection(*this);
}

//other constructors
NodeDirection::NodeDirection(const string& direction) : Node()
{
    this->direction = direction;
}

//public methods
string NodeDirection::interpret() throw()
{
    if (this->direction == "up")
    {
        return "向上";
    }
    else if (this->direction == "down")
    {
        return "向下";
    }
    else if (this->direction == "left")
    {
        return "向左";
    }
    else if (this->direction == "right")
    {
        return "向右";
    }
    else
    {
        return "无效指令";
    }
}

//protected methods

//private methods

//others
